<script setup lang="ts">
import { ref, watch } from 'vue';

let text=ref("")

const jinci=["你","我","他"]

watch(
    ()=>text.value,
    (nv,ov)=>{
        console.log("ov",ov);
        console.log("nv",nv);

        jinci.forEach(s=>{
            if(nv.includes(s)){
                

                let hefa_text=nv.substring(0,nv.length-1);
                text.value=hefa_text;

                alert("您的回复中包含禁词")
            }
        })
    }
)
</script>

<template>
    <div>
        <input type="text" placeholder="请输入合法字符" v-model="text"></input>
    </div>
</template>

<style scoped>

</style>